package com.zr.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zr.service.PasssqServiceljc;
import com.zr.service.RejectServiceljc;
import com.zr.serviceImpl.PasssqServiceImplljc;
import com.zr.serviceImpl.RejectServiceImplljc;

public class RejectControllerljc extends HttpServlet{
	RejectServiceljc r = new RejectServiceImplljc();
	PasssqServiceljc p = new PasssqServiceImplljc();
	//驳回申请控制器
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("utf8");
		resp.setCharacterEncoding("utf8");
		PrintWriter pw = resp.getWriter();
		int sid = Integer.parseInt(req.getParameter("sid"));		
		String tname = req.getParameter("tname");	
		String sname = p.findStuname(sid);
		String nr = req.getParameter("nr");
		String sqsj = req.getParameter("sj");	
		String score = req.getParameter("score");
		String cname = req.getParameter("cname");	
		String zt = "已驳回申请";
		int id = Integer.parseInt(req.getParameter("id"));
		Date d = new Date();
		SimpleDateFormat sim = new SimpleDateFormat("YYYY年MM月dd日hh时mm分");
		String newsj = sim.format(d);
		boolean flag = r.rejectSQ(id, sid, sname,tname, cname, score, zt, sqsj, newsj, nr);
		if(flag){
			pw.write("1");
		}else{
			pw.write("0");
		}
		pw.flush();
		pw.close();
	}
}
